using System.Collections.Generic;

//基于前缀树的红点系统
namespace Jerry.UiFrame
{
    /// <summary>
    ///     红点的数据结构
    /// </summary>
    public class RedPointNode
    {
        public RedPointNode(string name)
        {
            this.name = name;
        }

        /// <summary>
        ///     该节点的名字
        /// </summary>
        /// <value></value>
        public string name { private set; get; }

        /// <summary>
        ///     该节点的红点数量
        /// </summary>
        public int redPointCnt { private set; get; }

        /// <summary>
        ///     该节点的父节点
        /// </summary>
        public RedPointNode parent { set; get; }

        /// <summary>
        ///     该节点的子节点
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, RedPointNode> children { set; get; } = new();

        /// <summary>
        ///     更新红点的数量
        /// </summary>
        public void UpdateRedPointCnt(int num)
        {
            redPointCnt += num;
            if (redPointCnt < -1) redPointCnt = -1;
        }
    }
}